package com.atguigu.stgy.admin.controller;

import com.atguigu.stgy.admin.service.LeaseTermService;
import com.atguigu.stgy.admin.service.impl.LeaseTermServiceImpl;
import com.atguigu.stgy.model.entity.LeaseTerm;
import com.atguigu.stgy.model.result.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

//

/**
 * 租期(lease_term)表控制层
 *
 * @author xxxxx
 */
@RestController
@Tag(name = "租期管理模块")
@RequestMapping("/admin/term")
public class LeaseTermController {
    /**
     * 服务对象
     */
    @Resource
    private LeaseTermService leaseTermService;

    @Operation(summary = "查询所有租期列表")
    @GetMapping("/list")
    public R<List<LeaseTerm>> list(){
        return R.ok(leaseTermService.list());
    }
    @Operation(summary = "删除指定租期")
    @DeleteMapping("/deleteById")
    public R deleteById(@RequestParam("id")Long id){
        leaseTermService.removeById(id);
        return R.ok();
    }
    @Operation(summary = "新增或更新租期")
    @PostMapping("/saveOrUpdate")
    public R saveOrUpdate(@RequestBody LeaseTerm leaseTerm){
        leaseTermService.saveOrUpdate(leaseTerm);
        return R.ok();
    }
}
